package com.chenyue.cm.live.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.chenyue.cm.base.dao.LcBaseMapper;
import com.chenyue.cm.base.service.BaseServiceImpl;
import com.chenyue.cm.live.dao.JdLiveViewRecordMapper;
import com.chenyue.cm.live.domain.JdLiveViewRecord;
import com.chenyue.cm.live.service.JdLiveViewRecordService;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.io.Serializable;


/**
 * @author chenyue-cm
 */
@Service(value = "JdLiveViewRecordService")
public class JdLiveViewRecordServiceImpl extends BaseServiceImpl<JdLiveViewRecord> implements JdLiveViewRecordService {

    private final JdLiveViewRecordMapper jdLiveViewRecordMapper;

    public JdLiveViewRecordServiceImpl(@Qualifier("jdLiveViewRecordMapper") JdLiveViewRecordMapper jdLiveViewRecordMapper) {
        this.jdLiveViewRecordMapper = jdLiveViewRecordMapper;
    }

    @Override
    @Resource(name = "jdLiveViewRecordMapper")
    public void setBaseMapper(LcBaseMapper<JdLiveViewRecord, Serializable> baseMapper) {
        this.baseMapper = baseMapper;
    }

    /**
     * 删除用户观看记录
     *
     * @param id 用户id
     */
    @Override
    public void delete(Integer id) {
        jdLiveViewRecordMapper.delete(
                new LambdaQueryWrapper<JdLiveViewRecord>()
                        .eq(JdLiveViewRecord::getUserId, id)
        );
    }
}
